/**
 * @Author: 陈瑞鹏
 * @Date:   2022-09-23 11:09:17
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-12-05 17:45:34
 */
import { GameFacade } from "../core/GameFacade";
import { PureMVCEvents } from "../core/PureMVCEvents";
import { redPointKey, redPointCalKey } from "./redPointEnum";

export class redPointCtrl {

    private static _instance: redPointCtrl = null;
    public static getInstance(): redPointCtrl {
        if (!redPointCtrl._instance) {
            redPointCtrl._instance = new redPointCtrl();
        }
        return redPointCtrl._instance;
    }

    public constructor() {
        this.pointData = new Array<redPointKey>();
    }


    /*--- DATA --------------------------------------------------------------*/
    private pointData: Array<redPointKey> = null;


    /*--- Private Function ---------------------------------------------------*/

    private _isShow(key: redPointKey): boolean {
        if (this.pointData[key]) return true;
        return false;
    }

    private setPointData = function (redpointKey: redPointKey, _isshow) {
        this.pointData[redpointKey] = _isshow;

    };

    private sendNotice(key: redPointCalKey) {
        GameFacade.getInstance().sendNotification(PureMVCEvents.UPDATE_RED_POINT, { key: key });
    }

    /*--- Public Function ----------------------------------------------------*/

    public getPointData() {
        return this.pointData;
    }

    public isShow(key: redPointKey): boolean {
        let _isshow = false;

        if (key != null) {
            _isshow = this._isShow(key);
        }
        return _isshow;
    }


    public isEnableCalRed(): boolean {
        return true;
        // let taskVo:TaskVo = TaskData.getInstance().getCurrentTaskVo();
        // return !taskVo || taskVo && taskVo.nTaskIndex > SystemOpen.getInstance().getGuideIndexEnd();
    }

    //计算红点 
    public cal(key: redPointCalKey) {

        /** 只需在这里增加红点计算方式 */
        let _isshow = false;
        let _keyarr;
        let _characterType;
        // console.log(key, "key");
        switch (key) {

            case redPointCalKey.OPEN_HERO_DETAIL:
                {
                    this.setPointData(redPointKey.open_hero_detail, false);
                }
                break;
        
        }
        this.sendNotice(key);
    }
}